package com.redis.controller;

import com.alibaba.fastjson.JSON;
import com.redis.domain.User;
import com.redis.util.RedisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Author： yu.Tan
 * @Date: 2020/9/1 10:31
 * @Description: 定时消息发布测试
 */
@EnableScheduling
@Component
public class PublisherController {

    private static final Logger log = LoggerFactory.getLogger(PublisherController.class);

    @Autowired
    private RedisUtils redisUtils;

//    @Scheduled(fixedRate = 5000)
//    public String pubMsg() {
//        User user = new User(1, "羽***", 26, "男", "四川xxxx市xxxxxx县");
//        String s = JSON.toJSONString(user);
//        redisUtils.publish("cctv1", s);
//        log.info("Publisher sendes Topic... ");
//        return "success";
//    }
}
